package com.example.leetcode;

public class ReverseList {
    ListNode listNode = new ListNode(1);


    public ListNode reverse(ListNode head){
        if (head==null) {
            return null;
        }
        ListNode pre= head;
        ListNode current=head.next;
        pre.next=null;
        while (current!=null){
            ListNode next= current.next;
            current.next=pre;

            pre=current;
            current=next;
        }
        return pre;
    }
}
